package com.lyz.dataStructure.algorithm.小米2020;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 19:38
 * @Description:
 **/



import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/9/11 19:38
 *@Description:
 **/
public class 最大连续子序列之和 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] st = s.split(" ");
        int[] arr = new int[st.length];
        for(int i =0;i<arr.length;i++){
            arr[i] = Integer.parseInt(st[i]);
        }
        System.out.println(maxSerialSum(arr));
    }

    public static int maxSerialSum(int[] arr){
        int max =0;
        int[] tem = new int[arr.length];
        for(int i =0;i<arr.length;i++){
            tem[i] =0;

        }
        if(arr[0]>0){
            tem[0] = arr[0];
        }else {
            tem[0] = 0;
        }
        for(int i =1;i<arr.length;i++){
            if(tem[i-1]+arr[i]>0){
                tem[i] =tem[i-1]+arr[i];
            }else {
                tem[i] = 0;
            }
        }
        for(int i =0;i<arr.length;i++){
            if(tem[i]>max){
                max = tem[i];
            }
        }
        return max;
    }
}
